package com.ylkj.member.dao.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.ylkj.common.base.BaseDaoHibernate;
import com.ylkj.member.dao.QuestionInfoDAO;

@Repository
public class QuestionInfoDAOImpl  extends BaseDaoHibernate implements QuestionInfoDAO {

	@SuppressWarnings("unchecked")
	@Override
	public List<com.ylkj.common.entity.QuestionInfo> queryQuestionInfoByPara(Map<String, Object> para) {
		List<String> paras = new ArrayList<String>();
		List<Object> values = new ArrayList<Object>();
		
		StringBuffer sb = new StringBuffer("from QuestionInfo a where 1=1");
		
//		if (para.get("contractId") != null && !para.get("contractId").equals("")) {
//			sb.append(" and contractId=:contractId");
//			paras.add("contractId");
//			values.add(para.get("contractId"));
//		}
		
		return getHibernateTemplate().findByNamedParam(sb.toString(), paras.toArray(new String[paras.size()]), values.toArray());
	}

	@Override
	public void addQuestionInfo(com.ylkj.common.entity.QuestionInfo questionInfo) {
		this.getHibernateTemplate().save(questionInfo);
	}

	@Override
	public void updateQuestionInfo(com.ylkj.common.entity.QuestionInfo questionInfo) {
		this.getHibernateTemplate().saveOrUpdate(questionInfo);		
	}

	@Override
	public void delQuestionInfo(com.ylkj.common.entity.QuestionInfo questionInfo) {
		this.getHibernateTemplate().delete(questionInfo);
	}

}
